//package com.mousika.sea.cloud.exception;
//
//import com.mousika.sea.core.exception.BusinessException;
//import org.springframework.stereotype.Component;
//import org.springframework.web.servlet.HandlerExceptionResolver;
//import org.springframework.web.servlet.ModelAndView;
//import org.springframework.web.servlet.view.json.MappingJackson2JsonView;
//
//import jakarta.servlet.http.HttpServletRequest;
//import jakarta.servlet.http.HttpServletResponse;
//@Component
//public class GlobalExceptionHandler implements HandlerExceptionResolver {
//
//    private final static String CODE = "code";
//    private final static String MESSAGE = "message";
//
//    @Override
//    public ModelAndView resolveException(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) {
//        ModelAndView modelAndView = new ModelAndView(new MappingJackson2JsonView());
//        if(e instanceof BusinessException) {
//            modelAndView.addObject(MESSAGE, e.getMessage());
//            modelAndView.addObject(CODE, "FAILED");
//        }
//        return modelAndView;
//    }
//}
